<!DOCTYPE html>
<html>
<head>
<title>req_assign</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<link rel="stylesheet" type="text/css"
	href="/codebase/fonts/font_roboto/roboto.css" />
<link rel="stylesheet" type="text/css" href="/codebase/dhtmlx.css" />
<script type="text/javascript" src="/codebase/dhtmlxform.js" />
<script type="text/javascript" src="/codebase/dhtmlxeditor.js" />  
<!-- <script type="text/javascript" src="/codebase/dhtmlx.js" /> -->
<style>

div#div_label1{	
	font-family: Roboto, Arial, Helvetica;
	font-size: 14px;
	color: #404040;
	overflow: auto;
	padding-left: 50px;
}

div#div_label2{	
	font-family: Roboto, Arial, Helvetica;
	font-size: 14px;
	color: #404040;
	overflow: auto;
	padding-left: 50px;
}

div#editorObj1 {
	width: 800px;
	height: 150px;
	border: 1px solid #dfdfdf;
}
div#editorObj2 {
	width: 800px;
	height: 150px;
	border: 1px solid #dfdfdf;
}



</style>
<script>
/*<![CDATA[*/
	var myTabbar,myForm, myEditor1,myEditor2,myForm2,form_attach;
	var dhxWins ;
	var customCss = {
		video_bitrate : "validate_magenta",
		video_codec : "validate_orange"
	};
	
	function doOnLoad() {
		//alert("onload req assign");
		var v=document.getElementById("assign_req_id").innerHTML;
		if (myForm) {
			myForm.unload();
			myForm = null;
		}
		myForm = new dhtmlXForm("form_req_base_info");
		//myForm.loadStruct("/common/testmanager/req_modify_detail_base_info.xml");
		myForm.loadStruct("/req/req_modify_detail_base_info_onload?req_id="+v,function(){
			
			var myEditor_req_introduction = myForm.getEditor("req_introduction");
			var myEditor_req_remark = myForm.getEditor("req_remark");
			myEditor_req_remark.setContentHTML("/req/get_req_remark?req_id="+v);
			myEditor_req_introduction.setContentHTML("/req/get_req_introduction?req_id="+v); 
			
			var is_leader=document.getElementById("is_leader").innerHTML;
			if(is_leader!="true"){
				myForm.disableItem("req_plan_date");
				myForm.disableItem("req_difficult");
				myForm.disableItem("req_workload");
				//myForm.disableItem("req_status");
				
					/* myForm.disableItem("req_orientation");
					myForm.disableItem("req_difficult");
					myForm.disableItem("technical_director");
					
				
					
					myForm.disableItem("actual_finish_date");
					myForm.disableItem("req_actual_workload");
					myForm.disableItem("node_value");
					myForm.disableItem("req_introduction");
					myForm.disableItem("req_remark");		 */					    
				}
			});
	/*	var v2=document.getElementById("in_act_work_load").innerHTML;
		myForm.setItemValue("in_act_work_load", v2);
		
		var v3=document.getElementById("in_req_status").innerHTML;
		myForm.setItemValue("in_req_status", v3);
		*/
		
		
		myForm.attachEvent("onChange", function (name, value){
		    if(name=="node_value"){
		    //	var g_req_id=document.getElementById("assign_req_id").innerHTML;
		    //	myForm.send("/req/get_node_value_date?req_id="+g_req_id+"&node_value="+value, function(){
		    myForm.send("/req/get_node_value_date", "get",get_node_value_date,true);
		    	
		    } 
		});
		    
		myForm.attachEvent("onValidateError", function (name, value, result){
			var tmp_label=myForm.getItemLabel(name);	
		
		    alert("校验【"+tmp_label+"】 值为【"+value+ "】 ， 请更正");
		});
		
		myForm.attachEvent("onButtonClick", function(name) {		
				
				if(name=="base_info_save_btn"){
					//alert("base_info_save");					
				//	var is_leader=document.getElementById("is_leader").innerHTML;
					//if(is_leader!="true"){
//						myForm.send("/req/req_modify_base_info_save_att","post",callback);		
//					}else{
						myForm.send("/req/req_modify_base_info_save","post",callback);		
	//				}
								
				}		
				
				
				var btn_tmp=name.split("_");
				if(btn_tmp[0]=="download"){
					//myForm.send("/req/req_assign_detail_page_download_att?att_id="+btn_tmp[1], "get", downloadcallback,true);
					window.location.href = "/req/req_assign_detail_page_download_att?att_id="+btn_tmp[1];
				}
				
				var btn_tmp=name.split("_");
				if(btn_tmp[0]=="del"){
					//myForm.send("/req/req_assign_detail_page_download_att?att_id="+btn_tmp[1], "get", downloadcallback,true);
					//window.location.href = "/req/req_assign_detail_page_del_att?att_id="+btn_tmp[1];
					 if(confirm("你确定要删除此附件？"))					 
				    {
						myForm.send( "/req/req_assign_detail_page_del_att?att_id="+btn_tmp[1], "get", del_callback,true);
				    }
				}
	
			});		
		
		
		
		myForm.attachEvent("onFileAdd",function(realName){
			myForm.disableItem("base_info_save_btn");			
		});
		
		myForm.attachEvent("onUploadComplete",function(count){
			//logEvent("<br></br>onUploadComplete "+count+" file"+(count>1?"s were":" was")+" uploaded");
			alert("上传"+count+"个文件完成.");
			myForm.enableItem("base_info_save_btn");
		});
		
		myForm.attachEvent("onUploadFail",function(realName){
			//logEvent("onUploadFail, file: "+realName);
			alert("上传文件"+realName+"失败，请检查上传文件大小");
			myForm.enableItem("base_info_save_btn");
		});
		
		myForm.attachEvent("onUploadFile", function(realName, serverName) {
			atts_add_gropid(arguments[2].att_gropid);
			atts_add_ids(arguments[2].att_ids);
			//var mu=myForm.getUploader("myFiles");
		});
		
		myForm.attachEvent("onFileRemove",function(realName,serverName){
			alert(onFileRemove);
		});
	}
	
	function atts_add_ids(ids) {
		var txt="";
		//var get_input_att_ids=myForm.getInput("att_id");
		//txt=get_input_att_ids.value;
		txt=myForm.getItemValue("att_id");
		if (txt==""){
			//get_input_att_ids.value=ids;
			myForm.setItemValue("att_id",ids);
		}else{
			//get_input_att_group.value=txt+","+ids;
			myForm.setItemValue("att_id",txt+","+ids);
		}				
		//att_group.hide=true;
		//atts.hidden=true;
	}
	
	function atts_add_gropid(g_id) {
		var txt="";
		//var get_input_att_group=myForm.getInput("att_group_id");
		//txt=get_input_att_group.value;
		txt=myForm.getItemValue("att_group_id");
		if (txt==""){
			//get_input_att_group.value=g_id;
			myForm.setItemValue("att_group_id",g_id);
		}else{
			//get_input_att_group.value=txt+","+g_id;
			myForm.setItemValue("att_group_id",txt+","+g_id);
		}				
		//att_group.hidden=true;
		//atts.hide=true;
	}
	
	function createWindow() {
		//alert("open_createWindow");
		var p = 0;		
		var id = "req_assign_window";
		//
		var w = 700;
		var h = 200;
		var x = 200;
		var y = 300;
		
		//
		dhxWins=new dhtmlXWindows();
		dhxWins.createWindow(id, x, y, w, h);
		dhxWins.window(id).setText("需求退回");
		
		dhxWins.window(id).denyPark();
		dhxWins.window(id).button("park").hide();		
		dhxWins.window(id).attachURL("req_reject");	
	}
	
	function callback(){				
		if (arguments[1]=="true"){
			alert("保存基本信息成功");
			doOnLoad();
			//window.location.pathname="index";
		}else{
			alert("保存基本信息失败！callback : "+arguments[1]);
		}
	}
	function get_node_value_date(){		
    		if(arguments[1]==""){
    			myForm.setItemValue("node_value_date","");	
    		}else{		    			
    			myForm.setItemValue("node_value_date",arguments[1]);
    		}		    				    		
    	
	}
	function del_callback(){
		if (arguments[1]=="true"){
			alert("删除附件成功");
			//window.location.pathname="index";
			var v=document.getElementById("assign_req_id").innerHTML;
			//myForm.loadStruct("/req/req_modify_detail_base_info_onload?req_id="+v);
			doOnLoad();
		}else{
			alert("删除附件失败！callback : "+arguments[1]);
		}
		
	}

	/*]]>*/
</script>
</head>
<body onload="doOnLoad();">
<div id="assign_req_id" name="assign_req_id" th:text="${req_id}" style="display: none;" > </div>
<div id="is_leader" name="is_leader" th:text="${is_leader}" style="display: none;" > </div>
<div id="in_act_work_load" name="in_act_work_load" th:text="${in_act_work_load}"  style="display: none;"> </div>
<div id="in_req_status" name="in_req_status" th:text="${in_req_status}" style="display: none;" > </div>
	<table>
		<tr>
			<td>
				<div id="form_req_base_info" ></div>
			</td>
		</tr>
	</table>
	<table>
		<tr>
			<td>
				<div id="my_tabbar" ></div>
			</td>
		</tr>
	</table>
<table>
		<tr>
			<td>
				<div id="div_attacher" ></div>
			</td>
		</tr>
	</table>

	
</body>
</html>